home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / SOURCE.BIN / DefaultData.java < prev    next >
Encoding:
Java Source  |  1997-06-19  |  2.6 KB  |  97 lines

  1. /*
  2.  * DefaultData.java   1.0   12 Jan 1997
  3.  *
  4.  * Copyright (c) 1996 Krumel & Associates, Inc.  All Rights Reserved.
  5.  *
  6.  * This software is provided as is.  Krumel & Associates shall not be liable
  7.  * for any damages suffered by licensee as a result of using, modifying or
  8.  * distributing this software or its derivatives.
  9.  */
  10.  
  11. package symantec.itools.db.awt;
  12.  
  13. //This class is designed to work with the DefaultDataSource, but with care should be
  14. //usable by other DataSource classes.
  15. //
  16. //CAUTION - CAUTION - CAUTION
  17. //A TableCell should never hold onto this object (or any other Data object) for more
  18. //than one invocation because a DataSource will usually reuse this object.
  19. public class DefaultData implements Data {
  20.     int         row;
  21.     int         col;
  22.     DataSource  dataSource;
  23.  
  24.     public DefaultData(DataSource ds) {
  25.         dataSource = ds;
  26.     }
  27.  
  28.     public void setRowAndCol(int r, int c) {
  29.         row = r;
  30.         col = c;
  31.     }
  32.  
  33.     public int type() {
  34.         return dataSource.type(row, col);
  35.     }
  36.  
  37.     public boolean isEditable(int row, int col) {
  38.         return dataSource.isDataEditable(row, col);
  39.     }
  40.  
  41.     public boolean changed() { return false; }
  42.  
  43.     public void rollback() {}
  44.  
  45.     public void commit() {}
  46.  
  47.     public boolean supportsChoice() {
  48.         return dataSource.supportsChoice(row, col);
  49.     }
  50.  
  51.     public Data[] getChoices() throws TypeNotSupported {
  52.         return dataSource.getChoices(row, col);
  53.     }
  54.  
  55.     public void setText(String t) {
  56.         dataSource.setText(row, col, t);
  57.     }
  58.  
  59.     //pos is space where to be inserted (0 = first char)
  60.     public void insertChar(int pos, char c) {
  61.         //this will most likely throw a STringIndexOUtOfBoundsException
  62.         dataSource.insertChar(row, col, pos, c);
  63.     }
  64.  
  65.     public void setText(char c) {
  66.         setText(String.valueOf(c));
  67.     }
  68.  
  69.     public void appendChar(char c) {
  70.         dataSource.appendChar(row, col, c);
  71.     }
  72.  
  73.     public void clearText() {
  74.         dataSource.clearText(row, col);
  75.     }
  76.  
  77.     public void deleteChar(int pos) {
  78.         //this will most likely throw a STringIndexOUtOfBoundsException
  79.         dataSource.deleteChar(row, col, pos);
  80.     }
  81.  
  82.     public String subString(int spos, int epos) {
  83.         return dataSource.subString(row, col, spos, epos);
  84.     }
  85.  
  86.     public void setImage(java.awt.Image i) {
  87.         dataSource.setImage(row, col, i);
  88.     }
  89.  
  90.     public String toString() {
  91.         return dataSource.toString(row, col);
  92.     }
  93.  
  94.     public java.awt.Image toImage() {
  95.         return dataSource.toImage(row, col);
  96.     }
  97. }